package cn.wolfcode.crm.domain;

import lombok.*;

import java.util.List;

@Setter
@Getter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class PageResult {
	//用户提供参数	
	private int pageSize=5;
	private int currentPage=1;
	//Dao查询出来的参数
	private int rows;
	private List<?> result;
	//计算出来的参数
	private int prevPage;
	private int nextPage;
	private int totalPage;
	
	public PageResult(int pageSize, int currentPage, int rows, List<?> result) {
		super();
		this.pageSize = pageSize;
		this.currentPage = currentPage;
		this.rows = rows;
		this.result = result;
		if(rows <= pageSize){
			this.prevPage = 1;
			this.nextPage = 1;
			this.totalPage = 1;
			return;
		}
		this.totalPage=rows%pageSize==0?rows/pageSize:rows/pageSize+1;
		this.nextPage=currentPage+1<totalPage?currentPage+1:totalPage;
		this.prevPage =currentPage-1>1?currentPage-1:1;
	}



	
	
	
	
	
	
	
	
	
	
	
}
